package com.nzj.bandcampdroid;

import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;

import java.io.IOException;

public class MainActivity extends Activity
{
   MediaPlayer _player;

   @Override
   protected void onCreate(Bundle savedInstanceState)
   {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      try
      {
         _player = new MediaPlayer();
         _player.setDataSource(this, Uri.parse("http://popplers5.bandcamp.com/download/track?enc=mp3-128&fsig=d401c1b1788b26f998b341f54f836400&id=1269403107&stream=1&ts=1373796815.0"));
         _player.prepare();
         _player.start();
      }
      catch (IOException e)
      {
         Log.e("error", e.getMessage(), e);
      }
   }

   @Override
   public boolean onCreateOptionsMenu(Menu menu)
   {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
   }

   @Override
   public void onStop()
   {
      _player.release();
      _player = null;
      super.onStop();
   }
    
}
